from Crypto.PublicKey import RSA

# 生成密钥对
key = RSA.generate(2048)

# 生成私钥
private_key = key.export_key()
with open("private_key.pem", "wb") as f:
    f.write(private_key)

# 生成公钥
public_key = key.publickey().export_key()
with open("../apps/pay/key/ali_public_key.pem", "wb") as f:
    f.write(public_key)

print("私钥和公钥已生成并保存为 private_key.pem 和 ali_public_key.pem")